package com.wangdong.mijiqiqi.threetype;

import android.widget.ListView;
import android.widget.Toast;

import com.wangdong.mijiqiqi.R;
import com.wangdong.mijiqiqi.adapter.Result;
import com.wangdong.mijiqiqi.adapter.ShowAdapter;
import com.wangdong.mijiqiqi.threetype.presenter.DataBasePresenter;

import java.util.List;


public class ThreeActivity extends BaseThreeActivity<List<Result>> {


    private ListView listview;
    private ShowAdapter mAdapter;
    private PageRequest request;

    @Override
    protected int getContentResId() {
        return R.layout.activity_three;
    }

    @Override
    protected void initView() {
        super.initView();
        listview = (ListView) findViewById(R.id.listview);
        groupPresenter.getData(getRequest(), getUrl(), getApi());
    }

    @Override
    protected String getSubTitle() {
        return "好好学习天天向上";
    }


    @Override
    public void showData(List<Result> data) {
        ShowView(data);

    }
    @Override
    public void setPresenter(DataBasePresenter presenter) {

    }

    @Override
    public void showError(String message) {
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();

    }

    @Override
    protected Class getApi() {
        return Apijsonbean.class;
    }

    @Override
    protected PageRequest getRequest() {

             request =   new PageRequest();
                    request.setKey("3312524073fc51755f3e283116b8deb5");
        return request;
    }

    @Override
    protected String getUrl() {
        return "http://apis.juhe.cn/lottery/types";
    }
    /**
     * View 显示数据
     *

     */
    private void ShowView(List<Result> results) {


            if (mAdapter == null) {
                mAdapter = new ShowAdapter(results);
                listview.setAdapter(mAdapter);
            } else {
                mAdapter.addData(results);
            }


        }



}
